#include<bits/stdc++.h>
using namespace std;
struct node{
	int d,v,a;
}car[100005];
int p[100005],used[3005][3005];
int idx[100005];
int main()
{
	freopen("detect.in","r",stdin);
	freopen("detect.out","w",stdout);
	int t;
	cin>>t;
	while(t--)
	{
		memset(used,0,sizeof(used));
		memset(idx,0,sizeof(idx));
		int n,m,l,v;
		cin>>n>>m>>l>>v;
		for(int i=1;i<=n;i++) cin>>car[i].d>>car[i].v>>car[i].a;
		for(int i=1;i<=m;i++) cin>>p[i];
		for(int i=1;i<=m;i++)
		{
			for(int j=1;j<=n;j++)
			{
				if(car[j].d>p[i]) continue;
				int s=p[i]-car[j].d;
				double speed=sqrt(car[j].v*car[j].v+2*car[j].a*s);
				if(speed>v) idx[j]++,used[j][idx[j]]=p[i];
			}
		}
		int cnt=0,x=0;
		for(int i=1;i<=n;i++) if(idx[i]!=0) cnt++;
		for(int i=m;i>=1;i--) 
		{
			bool flag=1;
			for(int j=1;j<=n;j++)
			{
				if(idx[j]==1 and used[j][idx[j]]==p[i]) 
				{
					flag=0;
					break;
				}
			}
			if(flag)
			{
				x++;
				for(int j=1;j<=n;j++)
				{
					if(idx[j]>1 and used[j][idx[j]]==p[i]) idx[j]--;
				}
			}
		}
		cout<<cnt<<" "<<x<<endl;
	}
	return 0;
}
